/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package org.cip.esymons.eventos.bc;


import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;
import org.cip.esymons.general.bc.AreaFacadeLocal;
import org.cip.esymons.general.be.Area;

/**
 *
 * @author oscar
 */
public class AreaDelegate {

    AreaFacadeLocal local;

    public AreaDelegate() {
        local=lookupAreaFacade();
    }

    public Area buscar(Integer id){
        return local.find(id);
    }

    public List<Area> listarTodos(){
        return local.findAll();
    }

    private AreaFacadeLocal lookupAreaFacade() {
        try {
            Context c = new InitialContext();
            return (AreaFacadeLocal) c.lookup("java:comp/env/AreaFacade");
        } catch (NamingException ne) {
            Logger.getLogger(getClass().getName()).log(Level.SEVERE, "exception caught", ne);
            throw new RuntimeException(ne);
        }
    }
    

}
